﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using NuGet.Enterprise.Server.Configuration;

namespace NuGet.Enterprise.Server.Configuration
{
    public class BuildStoreSection
        : ConfigurationSection
    {
        #region Statics

        /// <summary>
        /// Gets the current <see cref="BuildStoreSection"/> instance.
        /// </summary>
        /// <value>The current instance.</value>
        public static BuildStoreSection Current
        {
            get
            {
                BuildStoreSection section = ConfigurationManager.GetSection(SectionName) as BuildStoreSection;

                return (section ?? new BuildStoreSection());
            }
        }

        #endregion

        #region Fields

        /// <summary>
        /// Gets the section naem.
        /// </summary>
        public const string SectionName = "nuGet.server/storage/buildStore";

        #endregion

        #region Properties

        [ConfigurationProperty("connections", IsDefaultCollection = false)]
        [ConfigurationCollection(typeof(BuildStoreConnectionCollection), AddItemName="add", ClearItemsName="clear", RemoveItemName="remove")]
        public BuildStoreConnectionCollection Connections
        {
            get
            {
                return (base["connections"] as BuildStoreConnectionCollection) ?? new BuildStoreConnectionCollection();
            }
            set
            {
                base["connections"] = value;
            }
        }

        #endregion
    }
}